package com.hszh.common.controller.other;

import com.hszh.common.dto.other.BoxType;
import com.hszh.common.dto.other.DropdownListBoxTypeDto1;
import com.hszh.common.convert.WmsBoxTypeCovertBasic;
import com.power.common.util.DateTimeUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/test")
public class MapperTestController {

  @GetMapping("convert")
  public  Object ConvertEntity() {
      //for demo test
      BoxType wmsBoxType = new BoxType();
      wmsBoxType.setName("1号箱");
      wmsBoxType.setNo("00001");
      wmsBoxType.setComment("未使用");
      wmsBoxType.setLength(100.0f);
      wmsBoxType.setWidth(100.0f);
      wmsBoxType.setHeight(100.0f);
      String now = DateTimeUtil.nowStrTime();
      wmsBoxType.setCreateTime(now);
      wmsBoxType.setCreateUser("admin");
      wmsBoxType.setUpdateTime(now);
      wmsBoxType.setUpdateUser("admin");
      wmsBoxType.setDeleteTime(now);
      wmsBoxType.setDeleteUser("admin");

      //数组
      List<Object> objectList = new ArrayList<>();
      objectList.add(wmsBoxType);

      // 使用mapstruct
      DropdownListBoxTypeDto1 dropdownListBoxTypeDto1 = WmsBoxTypeCovertBasic.INSTANCE.toConvertVO1(wmsBoxType);
      objectList.add("dropdownListBoxTypeDto1:" + WmsBoxTypeCovertBasic.INSTANCE.toConvertVO1(wmsBoxType));
      objectList.add("dropdownListBoxTypeDto1转换回实体类WmsBoxType:" + WmsBoxTypeCovertBasic.INSTANCE.fromConvertEntity1(dropdownListBoxTypeDto1));
      // 输出转换结果
      objectList.add("DropdownListBoxTypeDto2:" + " | " + WmsBoxTypeCovertBasic.INSTANCE.toConvertVO2(wmsBoxType));

      return objectList;
  }
}
